﻿using System;
using Entities.DataBase.Persistent;

namespace Entities.DataBase.Obj {

    public class CostUpdator {

        public int?    Type          { get; set; }
        public double? Amount     { get; set; }
        public int?    Status        { get; set; }
        public string  Currency    { get; set; }
        public string  Description { get; set; }

        public void UpdateCost(Cost cost) {
            cost.DateUpdated = DateTime.UtcNow;
            if (Type != null) {
                cost.Type = (int)Type;
            }

            if (Status != null) {
                cost.Status = (int)Status;
            }

            if (Amount != null) {
                cost.Amount = (decimal)Amount;
            }

            if (!string.IsNullOrEmpty(Description) && !cost.Description.Equals(Description)) {
                cost.Description = Description;
            }

            if (!string.IsNullOrEmpty(Currency) && !cost.Currency.Equals(Currency)) {
                 cost.Currency = Currency;
            }
        }

    }
}